package com.seguriapp.entities;

import java.util.LinkedHashMap;
import java.util.Map;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

import org.hibernate.annotations.Proxy;

import com.seguriapp.base.BaseEntity;

/**
 * Represents an Department entity.
 * 
 * @author Tania Gonzales(taniadgv@gmail.com)
 */
@Entity
@Table(name = "Department")
@Proxy(lazy = false)
public class Department extends BaseEntity {

  private static final long serialVersionUID = 6945161914411504104L;

  @Id
  @GeneratedValue
  private Long id;

  private String name;

  @ManyToOne(cascade = { CascadeType.PERSIST, CascadeType.MERGE })
  @JoinColumn(nullable = false, name = "countryId")
  private Country country;

  public Long getId() {
    return id;
  }

  public void setId(final Long id) {
    this.id = id;
  }

  public String getName() {
    return name;
  }

  public void setName(final String name) {
    this.name = name;
  }

  public Country getCountry() {
    return country;
  }

  public void setCountry(final Country country) {
    this.country = country;
  }

  @Override
  public Map<String, Object> toJsonString() {
    final Map<String, Object> map = new LinkedHashMap<String, Object>();
    map.put("id", id);
    map.put("name", name);
    map.put("country", country.toJsonString());
    return map;
  }

}
